#include <stdio.h>
#include <unistd.h>
#include "mpi.h"

int
main(int argc, char **argv)
{
	int size, rank;
	int success = 1;

	int myint[2] = {4,8};
	printf("before init\n");
	
	MPI_Init(&argc, &argv);
	
	MPI_Comm_size(MPI_COMM_WORLD, &size);
	MPI_Comm_rank(MPI_COMM_WORLD, &rank);

	printf("Size %d, Rank %d\n",size,rank);
	
	if( rank == 0 )
	{
		myint[0] = -1;
		myint[1] = -2;
		MPI_Bcast(myint,2,MPI_INT,0,MPI_COMM_WORLD);
		printf("BCAST_SEND: myint[0]: %d myint[1]: %d\n",myint[0], myint[1]);
	}
	else 
	{
		MPI_Bcast(myint,2,MPI_INT,0,MPI_COMM_WORLD);
		printf("BCAST_RECV: myint[0]: %d myint[1]: %d\n", myint[0], myint[1]);
		success = success && (myint[0] == -1);
		success = success && (myint[1] == -2);
	}
	
	if (success == 1) {
		printf("SUCCESS\n");
	}
	
	MPI_Finalize();
	return 0;
}

